<template>
	<view class="">
		<swiper class="swiper" circular :duration="duration" :indicatorDots="indicatorDots"
			indicator-color='rgba(235, 235, 235, 1)' indicator-active-color='rgba(81, 213, 128, 1)'
			@change='swiperChange'>
			<swiper-item>
				<view class="swiper-item ">
					<image :src="firstPage.pic" mode=""></image>
					<view class="swiper_cont" v-for="(i,v) in firstPage.desc" v-html="i">
					</view>

				</view>
			</swiper-item>
			<swiper-item>
				<view class="swiper-item ">
					<image :src="secondPage.pic" mode=""></image>
					<view class="swiper_cont" v-for="(i,v) in secondPage.desc" v-html="i">
					</view>
				</view>
			</swiper-item>
			<swiper-item>
				<view class="swiper-item ">
					<image :src="thirdPage.pic" mode=""></image>
					<view class="swiper_pro" v-for="(i,v) in thirdPage.desc" v-html="i">
					</view>
				</view>
			</swiper-item>
		</swiper>

		<view class="btn-section" v-if="current==2">
			<view class="marginTop-10 flex items-center  flex-center" @click="toggleCheckbox" >
				<up-checkbox :customStyle="{marginBottom: '5px'}" label="" shape="circle" size="16px" usedAlone
					v-model:checked="firstBrushingWords2" activeColor='#51D580'> </up-checkbox>
				<view class="fontSize-26 ">
					下次不再展示
				</view>
			</view>
			<view class="btn"  @click="goDetail()">
				开始刷
			</view>
		</view>

	</view>
</template>

<script setup>
	import {
		ref,
		inject,
		onMounted,
		reactive
	} from 'vue';
	import {
		onLoad,
		onUnload,
	} from '@dcloudio/uni-app';
	const duration = ref(500)
	const getBrushDescApi = inject('getBrushDesc')
	const indicatorDots = ref(true)
	const current = ref(0)
	const firstPage = ref({
		desc: '',
		pic: '',
	})
	const secondPage = ref({
		desc: '',
		pic: '',
	})
	const thirdPage = ref({
		desc: '',
		pic: '',
	})
	const wbook_id = ref('')
	const times_id = ref('')
	const firstBrushingWords2=ref(true)
	const toggleCheckbox = () => {
		firstBrushingWords2.value = !firstBrushingWords2.value;
	};
	onLoad((op) => {
		wbook_id.value = op.wbook_id
		times_id.value = op.times_id
		getBrushDescApi().then(res => {
			console.log(res, 83)
			firstPage.value = res.firstPage
			thirdPage.value = res.thirdPage
			secondPage.value = res.secondPage
			firstPage.value.desc = res.firstPage.desc.split('<br>')
			secondPage.value.desc = res.secondPage.desc.split('<br>')
			thirdPage.value.desc = res.thirdPage.desc.split('<br>')
			console.log(firstPage.value.desc)
		})
	})
	const swiperChange = (e) => {
		current.value = e.detail.current
	}
	const goDetail = (e) => {
		uni.setStorageSync("firstBrushingWords2", firstBrushingWords2.value)
		uni.redirectTo({
			url: '/pages/index/brushWords?wbook_id=' + wbook_id.value + '&times_id=' + times_id.value
		})
	}
</script>

<style scoped lang="scss">
	.swiper {
		height: 1126rpx;
	}

	.swiper-item {
		width: 686rpx;
		height: 1126rpx;
		background: rgba(81, 213, 128, 0.08);
		border-radius: 40rpx 40rpx 40rpx 40rpx;
		// opacity: 0.08;
		margin: 80rpx auto;

		image {
			width: 630rpx;
			height: 228rpx;
			display: block;
			margin: 24rpx auto;
		}

		.swiper_cont {
			width: 598rpx;
			font-family: PingFang SC, PingFang SC;
			font-weight: 400;
			font-size: 28rpx;
			color: #333;
			line-height: 39rpx;
			text-align: left;
			font-style: normal;
			text-transform: none;
			margin: 40rpx auto 0;
		}

		.swiper_pro {
			width: 598rpx;
			font-family: PingFang SC, PingFang SC;
			font-weight: bold;
			font-size: 30rpx;
			color: #333333;
			line-height: 39rpx;
			text-align: left;
			font-style: normal;
			text-transform: none;
			margin: 40rpx auto 0;
		}
	}

	.warn {
		font-weight: 400;
		font-size: 26rpx;
		color: #ccc;
		margin: 20rpx 0;
		text-align: center;
	}

	.btn-section {
		width: 100%;
		position: fixed;
		left: 50%;
		bottom: 30rpx;
		transform: translateX(-50%);
	}

	.btn {
		width: 702rpx;
		height: 104rpx;
		background: #51D580;
		border-radius: 92rpx 92rpx 92rpx 92rpx;
		text-align: center;
		line-height: 104rpx;
		font-family: PingFang SC, PingFang SC;
		font-weight: bold;
		font-size: 32rpx;
		color: #FFFFFF;
		margin: 0 auto;

	}
</style>